package com.itjiange;

/**
 * 遥控器
 *
 * @author ItJianGe
 * @data 2024/8/16 15:07
 */
public class Remote {

    private Command[] onCommand; // 开关命令集合
    private Command[] offCommand;

    public Remote() {
        onCommand = new Command[8];
        offCommand = new Command[8];

        // 初始化 16 个空键位
        for (int i = 0; i < 8; i++) {
            onCommand[i] = new NoCommand();
            offCommand[i] = new NoCommand();
        }
    }

    public void addCommand(int i, LightOnCommand lightOnCommand, LightOffCommand lightOffCommand) {
        onCommand[i] = lightOnCommand;
        offCommand[i] = lightOffCommand;
    }

    public void onButton(int i) {
        onCommand[i].execute();
    }

    public void offButton(int i) {
        offCommand[i].execute();
    }
}
